<!DOCTYPE html>
<!-- saved from url=(0056)http://startbootstrap.com/templates/simple-sidebar.html# -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Panel</title>
<script src="<?php echo base_url();?>js/chart.js"></script>
<?php $this->load->view('panel_head');?>
</head>

<body onload="startTime()">
<?php $this->load->view('panel_header');?>
<div style="height:46px;"></div>
<div id="wrapper"> 
  
  <!-- Sidebar -->
  <div id="sidebar-wrapper">
    <?php $this->load->view('panel_sidebar');?>
  </div>
  
  <!-- Page content -->
  <div id="page-content-wrapper">
    <div class="content-header">
      <h1><span class="glyphicon glyphicon-film"></span>&nbsp;Category</h1>
    </div>
    <!-- Keep all page content within the page-content inset div! -->
    
    <div class="page-content inset">
      <div class="row" style="margin-bottom:1em;">
        <div class="col-md-12" >
          <div style="float:left">
            
            <button type="button" class="btn btn-success" data-toggle="modal" data-target="#new_category"><span class="glyphicon glyphicon-plus-sign"></span>&nbsp;Create New Category</button>
            
            
          
          
         
          
          
          </div>
          
          <div style="float:right"></div>
        </div>
        <!-- <div class="col-md-12"> --> 
        
      </div>
      <!-- <div class="row"> -->
      
      <div class="row">
        <div class="col-md-12">
          <div style="float:right"> <?php echo count($category);?> items </div>
        </div>
        <!-- <div class="col-md-12"> --> 
      </div>
      <!-- <div class"row"> -->
       
      <div>
        <table class="table table-bordered">
       
          <tr class="info" align="center">
            <td width="55%" align="left" ><strong>Category Name</strong></td>
            <td width="15%"><strong>Vdo Files</strong></td>
            <td width="15%" ><strong>Size</strong></td>
            <td width="15%" colspan="2"><strong>Manage</strong></td>
          </tr>
          
          <?php $i=0; ?>
          <?php foreach($category as $category) { ?>
          <tr>
            <td><?php echo $category['category_name'];?></td>
            <td align="center"><?php 
					$this->db->where('category_id',$category['category_id']); 
					echo $check = $this->db->count_all_results('vdo')
				   ?> files</td>
            <td align="center">
			<?php
				  	$this->db->where('category_id',$category['category_id']); 
					$this->db->select_sum('vdo_size');
					$query = $this->db->get('vdo');
					$size = $query->result_array();					
					$bytes =  $size[0]['vdo_size'];
					
					$CI =& get_instance();
					$CI->load->library('calculate_byte');
					$vdofile_server = $CI->calculate_byte->index($bytes);
					
					printf ('%.2f ', $vdofile_server[0]);
                    echo $vdofile_server[1];
				  ?>
            </td>
            <td>
              <div align="center">
                <button class="btn btn-primary " data-toggle="modal" data-target="#edit_<?php echo $category['category_id'];?>"><span class="glyphicon glyphicon-edit"></span>&nbsp;Edit</button>
                <button class="btn btn-danger" data-toggle="modal" <?php if($check == 0) { ?>data-target="#delete_<?php echo $category['category_id'];?>"<?php } else { ?>data-target="#move_<?php echo $category['category_id'];?>"<?php } ?> style="height:34px;"><span class="glyphicon glyphicon-remove"></span></button>
              </div></td>
          </tr>
          
          <?php $i++;  }?>
          
          
         
        </table>
      </div>
      <!-- <div class="table-responsive"> --> 
      
      
      
       <!-- edit -->
      
      <?php $j = 0 ; ?>
      <?php foreach($edit as $edit) { ?>
      
     
     
<div class="modal fade " id="edit_<?php echo $edit['category_id'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel"><strong><?php echo $edit['category_name'];?></strong><a href ="<?php echo base_url();?>index.php/pmember/profile">
          </a>
        </h4>
      </div>
      
      <div class="modal-body">
      
      <?php echo form_open('pvdo/update_category/'.$edit['category_id']);?>
        <table width="100%">
          <tr  height="25em" >
            <td width="100%">
             
             <input type="text" class="form-control" placeholder="  Category Name" name="category_name" value="<?php echo $edit['category_name'];?>" required>
            </td>
          </tr>
        
          <tr>
            <td colspan="4" align="right" style="padding-top:0.65em"><button type="submit" class="btn btn-warning">Save</button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button></td>
        </table>
        <?php echo form_close();?>
        
      </div>
    </div>
  </div>
</div>


<!-- edit --> 





      
      <!-- Delete-->
<div class="modal fade " id="delete_<?php echo $edit['category_id'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Delete</h4>
      </div>
      <div class="modal-body">
      
      <?php echo form_open('pvdo/delete_category/'.$edit['category_id']);?>
      
        <table width="100%">
          <tr>
            <td  height="35em" style="vertical-align:top;">Are you sure you want to delete this?</td>
          </tr>
          <tr>
            <td align="right" ><button type="submit" class="btn btn-danger">Delete</button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Cancle</button></td>
          <tr>
        </table>
        
        <?php echo form_close();?>
        
        
      </div>
    </div>
  </div>
</div>
<!-- Delete--> 

      <!-- MoveData-->
<div class="modal fade " id="move_<?php echo $edit['category_id'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Delete &amp; Change Category</h4>
      </div>
      <div class="modal-body">
      
      <?php echo form_open('pvdo/change_category/'.$edit['category_id']);?>
      
        <table width="100%">
          <tr>
            <td  height="35em" style="vertical-align:top;">Change category vdo's to..</td>
          </tr>
          <tr>
          <td>
        
         
           <select class="form-control" name="category_id">
              <?php $move[$j] = $this->pvdo_model->get_category();?>
              <?php foreach ($move[$j] as $move)
			  {
				    if($move['category_name'] != $edit['category_name'])
					{
						echo '<option value="'.$move['category_id'].'">'.$move['category_name'].'</option>';
					}
			  }
			  ?>
              
            </select>
          </td>
          </tr>
          <tr>
            <td align="right" ><button type="submit" class="btn btn-danger"><span class="modal-title">Delete &amp; Change</span></button>
            </td>
          <tr>
        </table>
        <?php echo form_close();?>
        
        
      </div>
    </div>
  </div>
</div>
<!-- MoveData--> 

<?php $j++; } ?>

      
      
 <!-- new category -->
 <?php echo form_open('pvdo/new_category');?>
<div class="modal fade " id="new_category" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel"><strong>Create New Category</strong></h4>
      </div>
      
      <div class="modal-body">
        <table width="100%">
          <tr  height="25em" >
            <td width="100%">
             
             <input type="text" class="form-control" placeholder="  Category Name" name="category_name" required>
            </td>
          </tr>
        
          <tr>
            <td colspan="4" align="right" style="padding-top:0.65em"><button type="submit" class="btn btn-warning">Save</button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button></td>
        </table>
      </div>
    </div>
  </div>
</div>
<?php echo form_close();?>
<!-- new category  -->       
      
      
    </div>
    <!-- <div class="page-content inset"> --> 
    
  </div>
  <!--  <div id="page-content-wrapper"> --> 
  
</div>
<!-- <div id="wrapper"> --> 


<!-- Custom JavaScript for the Menu Toggle --> 
<script>
    $("#menu-toggle").click(function(e) {
        e.preventDefault();
        $("#wrapper").toggleClass("active");
    });
</script> 

<!-- checkbox --> 
<script>
$('#select-all').click(function(event) {   
    if(this.checked) {
        // Iterate each checkbox
        $(':checkbox').each(function() {
            this.checked = true;                        
        });
    }else{
		$(':checkbox').each(function() {
			this.checked = false;
		});
	}
});
</script>
</body>
</html>